package com.igeek.web;


import com.igeek.domain.Review;
import com.igeek.domain.User;
import com.igeek.service.ReviewService;
import com.igeek.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author spike
 * @since 2022-01-12
 */
@RestController
public class ReviewController {
    @Autowired
    private ReviewService reviewService;
    // var url = "foredoreview?oid=" + vue.o.id + "&pid=" + vue.p.id + "&content=" + vue.content;
    @PostMapping("/foredoreview")
    public Result foredoreview(Review review, HttpSession session,Integer oid){
        User user = (User) session.getAttribute("user");
        review.setUid(user.getId());
        reviewService.saveAndUpdateStatus(review,oid);
        return Result.success();
    }
}

